package com.easylinkin.linkappapi.ruleengine.service;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import com.easylinkin.linkappapi.device.entity.Device;
import com.easylinkin.linkappapi.ruleengine.entity.RuleEngine;
import java.util.List;
import org.springframework.transaction.annotation.Transactional;

/**
 * <p>
 * 智能规则引擎 服务类
 * </p>
 *
 * @author TongJie
 * @since 2020-08-24
 */
public interface RuleEngineService extends IService<RuleEngine> {

    /**
     * 触发 规则引擎 流水线 触发器-->条件器-->执行器
     *
     * @param device 设备vo
     * @param data
     */
    void triggerAssemblyLine(Device device, Object data);

    void add(RuleEngine ruleEngine);

    /**
     * 配置
     */
    @Transactional(rollbackFor = Exception.class)
    void setDetailConfig(RuleEngine ruleEngine);

    /**
     * 查询多条
     *
     * @param ruleEngine vo
     * @return result
     */
    List<RuleEngine> getRuleEngines(RuleEngine ruleEngine);

    /**
     * 分页查询
     *
     * @param page 分页参数
     * @param ruleEngine vo
     */
    IPage<RuleEngine> getRuleEngines(Page page, RuleEngine ruleEngine);

    /**
     * 单条查询
     */
    RuleEngine getRuleEngine(String id);

    /**
     * 修改规则引擎
     *
     * @param ruleEngine vo
     */
    void updateRuleEngine(RuleEngine ruleEngine);

    /**
     * 批量删除规则引擎
     *
     * @param ruleEngineList 规则引擎列表
     */
    @Transactional(rollbackFor = Exception.class)
    void deleteBatch(List<RuleEngine> ruleEngineList);

    /**
     * 触发
     */
    void trigger(RuleEngine ruleEngine);

    /**
     * 修改状态
     */
    void updateStatus(RuleEngine ruleEngine);

    /**
     * 禁用
     * @param tenantId
     */
    void disableByTenantId(String tenantId);

    /**
     * 批量禁用
     * @param tenantIdList
     */
    void disableByTenantIdBatch(List<String> tenantIdList);

    /**
     * 根据租户id 恢复
     * @param tenantId
     */
    void enableByTenantId(String tenantId);

    /***
     * 查询设备是否绑定
     * @param deviceCode
     * @return
     * @throws Exception
     */
    List<RuleEngine>  getDeviceCodeIsBind(String deviceCode) throws Exception;

    /***
     * 绑定设备
     * @param deviceCode
     * @param phone
     * @throws Exception
     */
    void ruleEngineBindDeviceCode(String deviceCode,String phone,String deviceTypeName) throws Exception;

    /***
     * 解除绑定
     * @param ruleEngine
     */
    void updateStatusBatch(RuleEngine ruleEngine);
}
